<template>
    <view @tap="__e" :class="['coupon-item', 'margin-v', 'data-v-453c9b9c', active ? 'active' : 'unactive']" :data-event-opts="[['tap', [['click', ['$event']]]]]">
        <view class="money-fl data-v-453c9b9c">
            <view class="price data-v-453c9b9c" v-if="baseCoupon.discount_type === 0">
                <text class="unit data-v-453c9b9c">¥</text>
                <text class="money data-v-453c9b9c">{{ baseCoupon.discount_money / 100 }}</text>
            </view>
            <block v-else>
                <view class="price data-v-453c9b9c" v-if="baseCoupon.discount_type === 1">
                    <text class="data-v-453c9b9c">{{ baseCoupon.discount_rate / 10 }}</text>
                    <text class="unit data-v-453c9b9c">折</text>
                </view>
                <block v-else>
                    <view class="price data-v-453c9b9c" style="font-size: 38rpx" v-if="baseCoupon.discount_type === 2">
                        <text class="data-v-453c9b9c">包邮</text>
                    </view>
                    <block v-else>
                        <view class="price data-v-453c9b9c" style="font-size: 36rpx" v-if="baseCoupon.discount_type === 3">
                            <text class="data-v-453c9b9c">兑换券</text>
                        </view>
                    </block>
                </block>
            </block>
            <view class="type data-v-453c9b9c">
                <text class="data-v-453c9b9c" v-if="baseCoupon.discount_type === 0">优惠券</text>
                <block v-else>
                    <text class="data-v-453c9b9c" v-if="baseCoupon.discount_type === 1">折扣券</text>
                    <block v-else>
                        <text class="data-v-453c9b9c" v-if="baseCoupon.discount_type === 2">运费券</text>
                        <block v-else>
                            <text class="data-v-453c9b9c" v-if="baseCoupon.discount_type === 3">兑换券</text>
                        </block>
                    </block>
                </block>
            </view>
        </view>
        <view class="detail data-v-453c9b9c">
            <view class="title data-v-453c9b9c">
                <text class="data-v-453c9b9c">{{ baseCoupon.title }}</text>
            </view>
            <view class="label data-v-453c9b9c" v-if="baseCoupon.score_price">
                <text class="data-v-453c9b9c" v-if="baseCoupon.score_price">{{ baseCoupon.score_price + scoreAlias + '兑换' }}</text>
            </view>
            <view class="valid-date data-v-453c9b9c">
                <text class="labels data-v-453c9b9c">{{ baseCoupon.usable_range_text }}</text>
                <text class="data-v-453c9b9c">{{ validDateStr }}</text>
            </view>
            <view class="limit-type gray data-v-453c9b9c">
                <view class="data-v-453c9b9c" v-if="coupon.max_money">
                    <text class="data-v-453c9b9c">{{ '最大' + coupon.max_money / 100 + '元可用' }}</text>
                </view>
                <view class="data-v-453c9b9c" v-if="coupon.draw_limit">
                    <text class="data-v-453c9b9c">{{ '抽数限制' + coupon.draw_limit }}</text>
                </view>
                <view class="data-v-453c9b9c" v-if="baseCoupon.discount_type === 0">
                    <text class="data-v-453c9b9c" v-if="baseCoupon.minimum_money">{{ '满' + baseCoupon.minimum_money / 100 + '元可用' }}</text>
                    <text class="data-v-453c9b9c" v-else>{{ '使用立减' + baseCoupon.discount_money / 100 + '元' }}</text>
                </view>
                <block v-else>
                    <view class="data-v-453c9b9c" v-if="baseCoupon.discount_type === 1">
                        <text class="data-v-453c9b9c" v-if="baseCoupon.minimum_money">{{ '满' + baseCoupon.minimum_money / 100 + '元' }}</text>
                        <text class="data-v-453c9b9c">{{ '享' + baseCoupon.discount_rate / 10 + '折优惠' }}</text>
                    </view>
                    <block v-else>
                        <view class="data-v-453c9b9c" v-if="baseCoupon.discount_type === 2">
                            <text class="data-v-453c9b9c" v-if="baseCoupon.minimum_money">{{ '满' + baseCoupon.minimum_money / 100 + '元' }}</text>
                            <text class="data-v-453c9b9c">享受包邮优惠</text>
                        </view>
                        <block v-else>
                            <view class="data-v-453c9b9c" v-if="baseCoupon.discount_type === 3">
                                <text class="data-v-453c9b9c">免费兑换指定的</text>
                                <text class="data-v-453c9b9c" v-if="baseCoupon.usable_range_type === 1">盲盒</text>
                                <block v-else>
                                    <text class="data-v-453c9b9c" v-if="baseCoupon.usable_range_type === 2">商品</text>
                                    <block v-else>
                                        <text class="data-v-453c9b9c" v-if="baseCoupon.usable_range_type === 3">VIP套餐</text>
                                    </block>
                                </block>
                            </view>
                        </block>
                    </block>
                </block>
            </view>
        </view>
        <view class="discount-money data-v-453c9b9c">
            <view class="action data-v-453c9b9c">
                <view class="btn data-v-453c9b9c" v-if="!isSelected">{{ '' + (active ? activeText : unActiveText) + '' }}</view>
                <view class="btnText data-v-453c9b9c" v-else>取消使用</view>
            </view>
        </view>
    </view>
</template>

<script>
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['components/UsableCouponPopup/components/CouponItem'],
    {
        '1b2a': function (t, n, e) {
            'use strict';

            e.d(n, 'b', function () {
                return o;
            });
            e.d(n, 'c', function () {
                return u;
            });
            e.d(n, 'a', function () {});
            var o = function () {
                this.$createElement;
                this._self._c;
            };
            var u = [];
        },
        '73a6': function (t, n, e) {
            'use strict';

            var o = e('4ea4');
            Object.defineProperty(n, '__esModule', {
                value: true
            });
            n.default = void 0;
            var u = o(e('8fc9'));
            var a = {
                name: 'CouponItem',
                props: {
                    backgroundColor: {
                        type: String,
                        default: '#ffffff'
                    },
                    coupon: {
                        type: Object,
                        default: function () {
                            return {};
                        }
                    },
                    isSelected: {
                        type: Boolean,
                        default: function () {
                            return false;
                        }
                    },
                    active: {
                        type: Number,
                        default: 1
                    },
                    activeText: {
                        type: String,
                        default: '立即使用'
                    },
                    unActiveText: {
                        type: String,
                        default: '已使用'
                    }
                },
                computed: {
                    baseCoupon: function () {
                        return this.coupon.base_coupon || {};
                    },
                    style: function () {
                        return 'background-color:' + this.backgroundColor;
                    },
                    validDateStr: function () {
                        var t = this.coupon.usable_start_at;
                        var n = this.coupon.usable_end_at;
                        if (!n) {
                            return '';
                        }
                        var e = (0, u.default)(t);
                        var o = (0, u.default)(n);
                        var a = new Date();
                        if (e > a || o < a) {
                            return e.format('YYYY.MM.DD') + ' - ' + o.format('MM.DD');
                        }
                        var c = o.diff(a, 'days');
                        return c < 1 ? o.diff(a, 'h') + 1 + '小时后过期' : c + 1 + '天后过期';
                    }
                },
                methods: {
                    click: function () {
                        this.$emit('click', this.coupon);
                    }
                }
            };
            n.default = a;
        },
        '8adf': function (t, n, e) {
            'use strict';

            var o = e('e243');
            e.n(o).a;
        },
        d810: function (t, n, e) {
            'use strict';

            e.r(n);
            var o = e('73a6');
            var u = e.n(o);
            for (var a in o) {
                if (['default'].indexOf(a) < 0) {
                    (function (t) {
                        e.d(n, t, function () {
                            return o[t];
                        });
                    })(a);
                }
            }
            n.default = u.a;
        },
        df52: function (t, n, e) {
            'use strict';

            e.r(n);
            var o = e('1b2a');
            var u = e('d810');
            for (var a in u) {
                if (['default'].indexOf(a) < 0) {
                    (function (t) {
                        e.d(n, t, function () {
                            return u[t];
                        });
                    })(a);
                }
            }
            e('8adf');
            var c = e('f0c5');
            var r = Object(c.a)(u.default, o.b, o.c, false, null, '453c9b9c', null, false, o.a, void 0);
            n.default = r.exports;
        },
        e243: function (t, n, e) {}
    }
]);
(global.webpackJsonp = global.webpackJsonp || []).push([
    'components/UsableCouponPopup/components/CouponItem-create-component',
    {
        'components/UsableCouponPopup/components/CouponItem-create-component': function (t, n, e) {
            e('543d').createComponent(e('df52'));
        }
    },
    [['components/UsableCouponPopup/components/CouponItem-create-component']]
]);
</script>
<style>
@import './CouponItem.css';
</style>
